'use strict';

const Controller = require('egg').Controller;

class BlogController extends Controller {
    
    async create() {
        const { ctx } = this;
        // 请求参数
        const { title, content, tag, type } = ctx.request.body;
        // 拿到请求用户
        const user_id = ctx.user.id;
        // 插入数据
        const res = await this.service.blog.create({
            title,
            content,
            tag,
            type,
            user_id,
        });
        // 是否插入成功
        ctx.body = 'hi, egg';
    }
}

module.exports = BlogController;
